#coding=utf-8
__author__ = 'Meteor'

import pytest
import time
import os
import seting
from tools.mock_server import run,stop


def run_mock(fun):
    def warp():
        if seting.is_user_mock:
            # 启动mock server
            run()
        fun()

        #完成后，关闭mock server
        if seting.is_user_mock:
            stop()
    return warp

@run_mock
def main():
    times = time.strftime('%Y%m%d%H%M%S',time.localtime())
    report_file = os.path.join(seting.BasePath,'report','%s.html' %times)

    pytest.main(['--html=%s' %report_file])

if __name__ == "__main__":
    main()